//
// Created by 86155 on 2025/4/16.
//

#ifndef LLVM_FEFRAMELOWERING_H
#define LLVM_FEFRAMELOWERING_H
#include "llvm/CodeGen/TargetFrameLowering.h"

namespace llvm {
class FeSubtarget;
class FeFrameLowering : public TargetFrameLowering{
  const FeSubtarget &STI;
public:
  explicit FeFrameLowering(const FeSubtarget &STI)
      : TargetFrameLowering(StackGrowsDown,
                            Align(16),
                            0,Align(16)),
        STI(STI) {}
  void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;

  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;

  void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override;
protected:
  bool hasFP(const MachineFunction &MF) const override;//帧指针实现
private:
  uint64_t computeStateSize(MachineFunction &MF) const;
};
}


#endif // LLVM_FEFRAMELOWERING_H
